home *** CD-ROM | disk | FTP | other *** search
- unit RTTIEgU;
-
- {$ifdef Ver80} { Delphi 1.0x }
- {$define DelphiLessThan5}
- {$endif}
- {$ifdef Ver90} { Delphi 2.0x }
- {$define DelphiLessThan5}
- {$endif}
- {$ifdef Ver93} { C++ Builder 1.0x }
- {$define DelphiLessThan5}
- {$endif}
- {$ifdef Ver100} { Delphi 3.0x }
- {$define DelphiLessThan5}
- {$endif}
- {$ifdef Ver110} { C++ Builder 3.0x }
- {$define DelphiLessThan5}
- {$endif}
- {$ifdef Ver120} { Delphi 4.0x }
- {$define DelphiLessThan5}
- {$endif}
- {$ifdef Ver125} { C++Builder 4.0x }
- {$define DelphiLessThan5}
- {$endif}
-
- interface
-
- uses
- WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls;
-
- type
- TForm1 = class(TForm)
- ListBox1: TListBox;
- Button1: TButton;
- Label1: TLabel;
- Edit1: TEdit;
- RadioButton1: TRadioButton;
- CheckBox1: TCheckBox;
- Button2: TButton;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- uses
- Typinfo;
-
- procedure TForm1.Button1Click(Sender: TObject);
- {$ifndef DelphiLessThan5}
- const
- PropName = 'Caption';
- Default = -1;
- var
- Loop, CaptionVal: Integer;
- Comp: TComponent;
- {$endif}
- begin
- {$ifndef DelphiLessThan5}
- for Loop := 0 to ComponentCount - 1 do
- begin
- Comp := Components[Loop];
- if IsPublishedProp(Comp, PropName) then
- begin
- CaptionVal := StrToIntDef(GetStrProp(Comp, PropName), Default);
- if CaptionVal <> Default then
- ListBox1.Items.Add(Format(
- 'The %s component %s has a numeric caption: %d',
- [Comp.ClassName, Comp.Name, CaptionVal]))
- end
- end
- {$endif}
- end;
-
- procedure TForm1.Button2Click(Sender: TObject);
- const
- PropName = 'Caption';
- Default = -1;
- var
- Loop, CaptionVal: Integer;
- Comp: TComponent;
- PropInfo: PPropInfo;
- begin
- for Loop := 0 to ComponentCount - 1 do
- begin
- Comp := Components[Loop];
- PropInfo := GetPropInfo(Comp.ClassInfo, PropName);
- if Assigned(PropInfo) then
- begin
- CaptionVal := StrToIntDef(GetStrProp(Comp, PropInfo), Default);
- if CaptionVal <> Default then
- ListBox1.Items.Add(Format('The %s component %s has a numeric caption: %d', [Comp.ClassName, Comp.Name, CaptionVal]))
- end
- end
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- SendMessage(ListBox1.Handle, LB_SETHORIZONTALEXTENT, 800, 0)
- end;
-
- end.
-